package cn.sdxx.qddata.service.impl;

import cn.sdxx.qddata.entity.District;
import cn.sdxx.qddata.entity.User;
import cn.sdxx.qddata.mapper.DistrictMapper;
import cn.sdxx.qddata.mapper.UserMapper;
import cn.sdxx.qddata.service.DistrictService;
import cn.sdxx.qddata.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DistrictServiceImpl extends ServiceImpl<DistrictMapper, User> implements DistrictService {

    @Autowired
    private DistrictMapper districtMapper;

    //根据父级id获取地区列表
    @Override
    public List<District> getDistinctByParent(String parent) {

//        System.out.println(parent);
        List<District> list = districtMapper.findByParent(parent);
        /**
         * 在进行网络数据传输是，为了尽量避免无效数据的传输，可以将无效数据设置为null
         * 可以节省流量，另一方面提升了效率
         */
        for(District d : list){
            d.setId(null);
            d.setParent(null);
        }
        return list;

    }
}
